#ifndef BUTTONITEMDELEGATE_H
#define BUTTONITEMDELEGATE_H

#ifdef COMMONCTRL_LIB
# define COMMONCTRL_EXPORT Q_DECL_EXPORT
#else
# define COMMONCTRL_EXPORT Q_DECL_IMPORT
#endif

#include <QStyledItemDelegate>
#include <QVector>
#include <QPushButton>

class COMMONCTRL_EXPORT ButtonItemDelegate : public QStyledItemDelegate
{
	Q_OBJECT

public:
	ButtonItemDelegate(QObject *parent);
	~ButtonItemDelegate();

	void	setEnable(bool	bEnable);
	void	setVectorButton(QVector<QPushButton*>&  vetButton);
	void	setColumnIndex(int nIndex);
protected:
	virtual void	onMouseRelease(int,QModelIndex) {}
	virtual void	onMousePress(int,QModelIndex){}
protected:
	void	paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
	bool	editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
	QSize   sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
private:
	int		m_nColumnIndex;
	QVector<QPushButton*>	m_vetButton;
	int		m_nSpacing;
	int		m_nWidth;
	int		m_nHeight;
	bool	m_bEnable;

	QPoint	m_ptMouse;

	enum  MouseState{
		MouseEmty,
		MouseMove,
		MousePress,
	};

	MouseState	m_mouseState;



};

#endif // BUTTONITEMDELEGATE_H
